home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / stealtagline.thor < prev    next >
Text File  |  1998-05-24  |  3KB  |  122 lines

  1. /*
  2. **  $VER: StealTagline.thor 1.7 (4.6.96)
  3. **
  4. **  StealTagline.thor
  5. **
  6. **  Steals taglines from the current message
  7. **
  8. **  Author: Magne Østlyngen
  9. **
  10. **  (C)1994-1996 Ultima Thule Software
  11. */
  12.  
  13. options results
  14.  
  15. Globals = 'HEADTAGS. TEXTTAGS. thorport msg.bbsname msg.confname Globals'
  16.  
  17. p=address()||' '||show('P',,);if pos('THOR.',p)>0 then thorport=word(,
  18. substr(p,pos('THOR.',p)),1);else do;say 'No THOR port found!';exit 10;end
  19.  
  20. if ~show('p','BBSREAD') then do;address command;
  21. "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead";"WaitForPort BBSREAD";end
  22.  
  23. address(thorport)
  24. CURRENTMSG STEM msg
  25. if rc~=0 then error('"CURRENTMSG failed: '||THOR.LASTERROR||'"')
  26.  
  27. address BBSREAD
  28. drop HEADTAGS. TEXTTAGS.
  29. READBRMESSAGE '"'||msg.bbsname||'"' '"'||msg.confname||'"' msg.msgnr headstem HEADTAGS textstem TEXTTAGS
  30. if rc~=0 then error('"READBRMESSAGE failed: '||BBSREAD.LASTERROR||'"')
  31.  
  32. call ProcessMessagePart('HEADTAGS', 'TEXTTAGS')
  33.  
  34. drop HEADTAGS. TEXTTAGS.
  35.  
  36. exit 0
  37.  
  38. ProcessMessagePart:
  39.     interpret 'procedure expose' Globals
  40.     parse arg hstem, tstem
  41.  
  42.     if symbol(tstem'.TEXT.COUNT')='VAR' then call ProcessText(tstem'.TEXT.')
  43.  
  44.     if(symbol(tstem'.PART.COUNT') = "VAR") then do
  45.         parts = value(tstem'.PART.COUNT')
  46.         do n=1 to parts
  47.             call ProcessMessagePart(tstem'.PART.'n'.MSG', tstem'.PART.'n'.MSG')
  48.         end
  49.     end
  50. return 0
  51.  
  52.  
  53. ProcessText:
  54.     interpret 'procedure expose' Globals
  55.     parse arg tstem
  56.  
  57.     drop txt.
  58.  
  59.     ln = value(tstem'count')
  60.     if ln=0 then return 0
  61.     do while value(tstem||ln) = ""
  62.         ln = ln - 1
  63.     end
  64.  
  65.     nl = 0
  66.     do n = 1 to ln /* FIX: gå ovenfra */
  67.         if value(tstem||n) = "" then nl = n
  68.     end
  69.  
  70.     txt.count = ln-nl
  71.  
  72.     n = 1
  73.     do i = nl + 1 to ln
  74.         txt.n = value(tstem||i)
  75.         n = n + 1
  76.     end
  77.  
  78.     address(thorport)
  79.     drop out.
  80.     REQUESTLIST txt out '"Select lines to steal"' DRAGSELECT SIZEGADGET
  81.     if rc=5 then return 0
  82.     if rc~=0 then error('"REQUESTLIST failed: '||THOR.LASTERROR||'"')
  83.     if out.count=0 then return 0
  84.     drop txt.
  85.  
  86.     address BBSREAD
  87.     GETCONFDATA '"'||msg.bbsname||'" "'||msg.confname||'"' conf
  88.     if rc~=0 then error('"GETCONFDATA failed: '||BBSREAD.LASTERROR||'"')
  89.     tagf=conf.tagfile
  90.     if(symbol("conf.tagfile")~="VAR")|(conf.tagfile="")then do
  91.         GETBBSDATA '"'||msg.bbsname||'"' bbs
  92.         if rc~=0 then error('"GETBBSDATA failed: '||BBSREAD.LASTERROR||'"')
  93.         tagf=bbs.tagfile
  94.         if(symbol("bbs.tagfile")~="VAR")|(bbs.tagfile="")then do
  95.             GETGLOBALDATA glob
  96.             if rc~=0 then error('"GETGLOBALDATA failed: '||BBSREAD.LASTERROR||'"')
  97.             tagf=glob.tagfile
  98.             if(symbol("glob.tagfile")~="VAR")|(glob.tagfile="")then error('"No tagfile configured"')
  99.         end
  100.     end
  101.  
  102.     address command "echo noline >>"||tagf
  103.  
  104.     if ~open(fil,tagf,A) then error('"Couldn'||"'"||'t open tagfile to append new tag"')
  105.  
  106.     tagline=""
  107.     do n = 1 to out.count
  108.         tagline = tagline||out.n
  109.         if n ~= out.count then tagline = tagline||'\n'
  110.     end
  111.     call writeln(fil,tagline)
  112.     call close(fil)
  113. return 0
  114.  
  115.  
  116. error: procedure expose thorport
  117.     parse arg err
  118.     address(thorport)
  119.     say REQUESTNOTIFY err '"_Ok"'
  120.     REQUESTNOTIFY err '"_Ok"'
  121. exit 0
  122.